import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ItemData } from "../../../resource/info/ItemData";
import { TweenLite } from "../../../../../com/greensock/TweenLite";
import { TimelineLite } from "../../../../../com/greensock/TimelineLite";
import { MountStartsEvents } from "../events/MountStartsEvents";
type int = number;
//class MountStartsMiniAlbum
    
    export  class MountStartsMiniAlbum /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._imgArr = [];
            MountStartsMiniAlbum._thisObj = this;
            this.scrollRect = new Object /* flash.geom.Rectangle */(0, 0, 369, 212);
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            LoaderHelp.addResCallBack(ResFileConst.mountstartsBigPic, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._loaded = true;
            var loc1=this.BmName;
            if (this.numChildren > 0) 
            {
                if (this._currentIndex >= 0) 
                {
                    loc1 = loc1 + (this._currentIndex + 1).toString();
                    (this.getChildAt((this.numChildren - 1)) as Object /* flash.display.Bitmap */).bitmapData = GlobalClass.getBitmapData(loc1);
                }
            }
            return;
        }

        public updateInfo(arg1: ItemData): void
        {
            this._mountIdata = arg1;
            return;
        }

        public addImgByIndex(arg1: int): void
        {
            if (arg1 == this._currentIndex) 
            {
                return;
            }
            var loc1=this.BmName;
            if (arg1 < this.OPENNUM && arg1 >= 0) 
            {
                loc1 = loc1 + (arg1 + 1).toString();
                if (this.numChildren != 0) 
                {
                    if (this._ttl != null) 
                    {
                        this._ttl.stop();
                    }
                    this.keepOneChild();
                    if (this._loaded) 
                    {
                        addChild(new Object /* flash.display.Bitmap */(GlobalClass.getBitmapData(loc1)));
                    }
                    else 
                    {
                        addChild(new Object /* flash.display.Bitmap */());
                    }
                    this._ttl = this.createTTL();
                    this._isTweening = true;
                    if (arg1 > this._currentIndex) 
                    {
                        this.moveLeft();
                    }
                    else 
                    {
                        this.moveRight();
                    }
                    this._currentIndex = arg1;
                }
                else 
                {
                    if (this._loaded) 
                    {
                        addChild(new Object /* flash.display.Bitmap */(GlobalClass.getBitmapData(loc1)));
                    }
                    else 
                    {
                        addChild(new Object /* flash.display.Bitmap */());
                    }
                    this._currentIndex = arg1;
                }
            }
            else if (arg1 < 0) 
            {
                this.addImgByIndex(0);
            }
            else if (arg1 >= this.OPENNUM) 
            {
                this.addImgByIndex((this.OPENNUM - 1));
            }
            return;
        }

        /* internal  */moveRight(): void
        {
            getChildAt(1).x = getChildAt(0).x - getChildAt(1).width;
            this._ttl.appendMultiple([new TweenLite(getChildAt(1), 0.5, {"x": 0}), new TweenLite(getChildAt(0), 0.5, {"x": getChildAt(0).width})]);
            return;
        }

        /* internal  */moveLeft(): void
        {
            getChildAt(1).x = getChildAt(0).width;
            this._ttl.appendMultiple([new TweenLite(getChildAt(1), 0.5, {"x": 0}), new TweenLite(getChildAt(0), 0.5, {"x":-getChildAt(0).width})]);
            return;
        }

        /* internal  */keepOneChild(): void
        {
            while (this.numChildren > 1) 
            {
                removeChildAt(0);
            }
            return;
        }

        public get isTweening(): Boolean
        {
            return this._isTweening;
        }

        /* internal  */createTTL(): TimelineLite
        {
            var loc1;
            return new TimelineLite({"onComplete":(): void
            {
                MountStartsMiniAlbum._thisObj.dispatchEvent(new MountStartsEvents(MountStartsEvents.TWEENING_COMPLETE, currentIndex));
                _isTweening = false;
                _ttl.stop();
                _ttl = null;
                return;
            }})
        }

        public get currentIndex(): int
        {
            return this._currentIndex;
        }

        public set currentIndex(arg1: int)
        {
            this._currentIndex = arg1;
            return;
        }

        /* internal */ /* const */OPENNUM: int=9;

        /* internal */ /* const */BmName: string="mountStartsBig_";

        /* internal */ /* var */_imgArr: Array<any>;

        /* internal */ /* var */_ttl: TimelineLite=null;

        /* internal */ /* var */_currentIndex: int=-1;

        /* internal */ /* var */_isTweening: Boolean=false;

        /* internal */ /* var */_loaded: Boolean;

        /* internal */ /* var */_mountIdata: ItemData;

        /* internal */ static /* var */_thisObj: MountStartsMiniAlbum;
    }
